import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BookingCheckinDetailApi } from '#/api/spa/booking/checkindetail';

import { z } from '#/adapter/form';
import {
    DICT_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'checkinMasterId',
      label: '签到主表ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入签到主表ID',
      },
    },
    {
      fieldName: 'detailCode',
      label: '明细编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入明细编码',
      },
    },
    {
      fieldName: 'sequenceNo',
      label: '明细序号',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入明细序号',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'customerPhone',
      label: '客户电话',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户电话',
      },
    },
    {
      fieldName: 'customerGender',
      label: '性别',
      component: 'Input',
      componentProps: {
        placeholder: '请输入性别',
      },
    },
    {
      fieldName: 'customerAge',
      label: '年龄',
      component: 'Input',
      componentProps: {
        placeholder: '请输入年龄',
      },
    },
    {
      fieldName: 'groupMemberId',
      label: '团体成员ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体成员ID',
      },
    },
    {
      fieldName: 'groupMemberSequence',
      label: '团体成员序号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体成员序号',
      },
    },
    {
      fieldName: 'isGroupLeader',
      label: '是否团体负责人',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'checkinStatus',
      label: '个人签到状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'expectedArrivalTime',
      label: '个人预计到店时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'actualArrivalTime',
      label: '个人实际到店时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'checkinTime',
      label: '个人签到时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'checkinMethod',
      label: '签到方式',
      component: 'Input',
      componentProps: {
        placeholder: '请输入签到方式',
      },
    },
    {
      fieldName: 'checkinUserId',
      label: '签到操作人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入签到操作人ID',
      },
    },
    {
      fieldName: 'checkinNotes',
      label: '个人签到备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入个人签到备注',
      },
    },
    {
      fieldName: 'isLate',
      label: '是否迟到',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'lateMinutes',
      label: '迟到分钟数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入迟到分钟数',
      },
    },
    {
      fieldName: 'lateReason',
      label: '迟到原因',
      component: 'Input',
      componentProps: {
        placeholder: '请输入迟到原因',
      },
    },
    {
      fieldName: 'convertedOrderId',
      label: '转换后的消费订单ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入转换后的消费订单ID',
      },
    },
    {
      fieldName: 'conversionTime',
      label: '转换时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'conversionUserId',
      label: '转换操作人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入转换操作人ID',
      },
    },
    {
      fieldName: 'specialRequirements',
      label: '特殊需求',
      component: 'Input',
      componentProps: {
        placeholder: '请输入特殊需求',
      },
    },
    {
      fieldName: 'healthNotes',
      label: '健康备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入健康备注',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'checkinMasterId',
      label: '签到主表ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入签到主表ID',
      },
    },
    {
      fieldName: 'detailCode',
      label: '明细编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入明细编码',
      },
    },
    {
      fieldName: 'sequenceNo',
      label: '明细序号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入明细序号',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'customerPhone',
      label: '客户电话',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户电话',
      },
    },
    {
      fieldName: 'customerGender',
      label: '性别',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入性别',
      },
    },
    {
      fieldName: 'customerAge',
      label: '年龄',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入年龄',
      },
    },
    {
      fieldName: 'groupMemberId',
      label: '团体成员ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体成员ID',
      },
    },
    {
      fieldName: 'groupMemberSequence',
      label: '团体成员序号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体成员序号',
      },
    },
    {
      fieldName: 'isGroupLeader',
      label: '是否团体负责人',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        placeholder: '请选择是否团体负责人',
      },
    },
    {
      fieldName: 'checkinStatus',
      label: '个人签到状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择个人签到状态',
      },
    },
    {
      fieldName: 'expectedArrivalTime',
      label: '个人预计到店时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'actualArrivalTime',
      label: '个人实际到店时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'checkinTime',
      label: '个人签到时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'checkinMethod',
      label: '签到方式',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入签到方式',
      },
    },
    {
      fieldName: 'checkinUserId',
      label: '签到操作人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入签到操作人ID',
      },
    },
    {
      fieldName: 'checkinNotes',
      label: '个人签到备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入个人签到备注',
      },
    },
    {
      fieldName: 'isLate',
      label: '是否迟到',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        placeholder: '请选择是否迟到',
      },
    },
    {
      fieldName: 'lateMinutes',
      label: '迟到分钟数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入迟到分钟数',
      },
    },
    {
      fieldName: 'lateReason',
      label: '迟到原因',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入迟到原因',
      },
    },
    {
      fieldName: 'convertedOrderId',
      label: '转换后的消费订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入转换后的消费订单ID',
      },
    },
    {
      fieldName: 'conversionTime',
      label: '转换时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'conversionUserId',
      label: '转换操作人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入转换操作人ID',
      },
    },
    {
      fieldName: 'specialRequirements',
      label: '特殊需求',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入特殊需求',
      },
    },
    {
      fieldName: 'healthNotes',
      label: '健康备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入健康备注',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BookingCheckinDetailApi.BookingCheckinDetail>['columns'] {
  return [
    {
      field: 'id',
      title: '签到明细ID',
      minWidth: 120,

    },
    {
      field: 'checkinMasterId',
      title: '签到主表ID',
      minWidth: 120,

    },
    {
      field: 'detailCode',
      title: '明细编码',
      minWidth: 120,

    },
    {
      field: 'sequenceNo',
      title: '明细序号',
      minWidth: 120,

    },
    {
      field: 'customerId',
      title: '客户ID',
      minWidth: 120,

    },
    {
      field: 'customerName',
      title: '客户姓名',
      minWidth: 120,

    },
    {
      field: 'customerPhone',
      title: '客户电话',
      minWidth: 120,

    },
    {
      field: 'customerGender',
      title: '性别',
      minWidth: 120,

    },
    {
      field: 'customerAge',
      title: '年龄',
      minWidth: 120,

    },
    {
      field: 'groupMemberId',
      title: '团体成员ID',
      minWidth: 120,

    },
    {
      field: 'groupMemberSequence',
      title: '团体成员序号',
      minWidth: 120,

    },
    {
      field: 'isGroupLeader',
      title: '是否团体负责人',
      minWidth: 120,

    },
    {
      field: 'checkinStatus',
      title: '个人签到状态',
      minWidth: 120,

    },
    {
      field: 'expectedArrivalTime',
      title: '个人预计到店时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'actualArrivalTime',
      title: '个人实际到店时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'checkinTime',
      title: '个人签到时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'checkinMethod',
      title: '签到方式',
      minWidth: 120,

    },
    {
      field: 'checkinUserId',
      title: '签到操作人ID',
      minWidth: 120,

    },
    {
      field: 'checkinNotes',
      title: '个人签到备注',
      minWidth: 120,

    },
    {
      field: 'isLate',
      title: '是否迟到',
      minWidth: 120,

    },
    {
      field: 'lateMinutes',
      title: '迟到分钟数',
      minWidth: 120,

    },
    {
      field: 'lateReason',
      title: '迟到原因',
      minWidth: 120,

    },
    {
      field: 'convertedOrderId',
      title: '转换后的消费订单ID',
      minWidth: 120,

    },
    {
      field: 'conversionTime',
      title: '转换时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'conversionUserId',
      title: '转换操作人ID',
      minWidth: 120,

    },
    {
      field: 'specialRequirements',
      title: '特殊需求',
      minWidth: 120,

    },
    {
      field: 'healthNotes',
      title: '健康备注',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

